import {
  Inject,
  Controller,
  Get,
  Query,
  Post,
  Body,
} from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { ArticleService } from '../service/article.service';

@Controller('/article')
export class ArticleController {
  @Inject()
  ctx: Context;

  @Inject()
  articleService: ArticleService;

  @Get('/finds')
  async finds(@Query() data: any): Promise<any> {
    const result = await this.articleService.finds(data);
    return result;
  }

  @Get('/findHots')
  async findHots(@Query() data: any): Promise<any> {
    const result = await this.articleService.findHots(data);
    return result;
  }

  @Get('/find')
  async find(@Query() data: any): Promise<any> {
    const result = await this.articleService.find(data);
    return result;
  }

  @Post('/add')
  async add(@Body() data: any): Promise<any> {
    const result = await this.articleService.add(data);
    return result;
  }

  @Get('/delete')
  async delete(@Query() data: any): Promise<any> {
    const result = await this.articleService.delete(data);
    return result;
  }

  @Post('/update')
  async update(@Body() data: any): Promise<any> {
    const result = await this.articleService.update(data);
    return result;
  }
}
